/*
 * @Author: silence
 * @Date: 2022-05-27 10:46:56
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-08-09 17:01:01
 * @Description: 
 */

import '../utils/Tool/MyTools.dart';
import 'MyEntityLog.dart';

class UserEntity {
  String? id;
  String? nickname;
  String? avatar;
  String? sex;
  String? birthday;
  String? vip_expires;
  String? is_trial_period;
  String? is_vip;
  String? vip_expires_type;
  String? vip_expires_text;
  String? phone;
  String? certification;
  String? coin;
  String? counts;
  String? score;

  /**是否绑定微信，’1‘绑定 */
  String? is_bind_wechat;

  /// 注册的设备id
  String? registrationId;

  /// 是否打开了推送消息: [0:否,1:是]
  String? isPush;

  UserEntity(
      {this.id,
      this.nickname,
      this.avatar,
      this.sex,
      this.birthday,
      this.vip_expires,
      this.is_trial_period,
      this.is_vip,
      this.vip_expires_type,
      this.vip_expires_text,
      this.phone,
      this.certification,
      this.coin,
      this.score,
      this.is_bind_wechat,
      this.counts,
      this.registrationId,
      this.isPush});

  /// 获取中间隐藏的newPhone
  phoneHideMiddle() {
    String newPhone = '';
    if (!MyTools.stringIsEmpty(this.phone) && this.phone!.length >= 11) {
      newPhone = this.phone!.replaceRange(3, 7, '****');
    }
    return newPhone;
  }

  UserEntity.fromJson(Map<String, dynamic> json) {
    id = MyEntityLog.handleString(json, 'id');
    nickname = MyEntityLog.handleString(json, 'nickname');
    avatar = MyEntityLog.handleString(json, 'avatar');
    sex = MyEntityLog.handleString(json, 'sex');
    birthday = MyEntityLog.handleString(json, 'birthday');
    vip_expires = MyEntityLog.handleString(json, 'vip_expires');
    is_trial_period = MyEntityLog.handleString(json, 'is_trial_period');
    is_vip = MyEntityLog.handleString(json, 'is_vip');
    vip_expires_type = MyEntityLog.handleString(json, 'vip_expires_type');
    vip_expires_text = MyEntityLog.handleString(json, 'vip_expires_text');
    phone = MyEntityLog.handleString(json, 'phone');
    certification = MyEntityLog.handleString(json, 'certification');
    coin = MyEntityLog.handleString(json, 'coin');
    score = MyEntityLog.handleString(json, 'score');
    counts = MyEntityLog.handleString(json, 'counts');
    registrationId = MyEntityLog.handleString(json, 'registration_id');
    isPush = MyEntityLog.handleString(json, 'is_push');
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['nickname'] = this.nickname;
    data['avatar'] = this.avatar;
    data['sex'] = this.sex;
    data['birthday'] = this.birthday;
    data['vip_expires'] = this.vip_expires;
    data['is_trial_period'] = this.is_trial_period;
    data['is_vip'] = this.is_vip;
    data['vip_expires_type'] = this.vip_expires_type;
    data['vip_expires_text'] = this.vip_expires_text;
    data['phone'] = this.phone;
    data['certification'] = this.certification;
    data['coin'] = this.coin;
    data['score'] = this.score;
    data['counts'] = this.counts;
    data['is_bind_wechat'] = this.is_bind_wechat;
    data['registrationId'] = this.registrationId;
    data['isPush'] = this.isPush;

    return data;
  }

  @override
  String toString() {
    return 'UserEntity{id: $id, nickname: $nickname, avatar: $avatar, sex: $sex, birthday: $birthday, vip_expires: $vip_expires, is_trial_period: $is_trial_period, is_vip: $is_vip, vip_expires_type: $vip_expires_type, vip_expires_text: $vip_expires_text, phone: $phone, certification: $certification, coin: $coin, counts: $counts, score: $score, is_bind_wechat: $is_bind_wechat, registrationId: $registrationId, isPush: $isPush}';
  }
}
